package BogoCommands;

my %servercmds= qw(
	SERV_HELO    100 
	ACCEPT       130
	DENY         140
	UPDATE       180
	MOVE         410
	VERIFY       490
);
my %clientcmds=qw(
	INTRO        120
	READY        160
	GET_STATUS   200
	THROW_DIES   400
	MOVE_DONE    420
	AC_NONE      430
	AC_PAY       440
	DISCONNECT   999
);





sub getEnumbyName{
	my $type = shift;
	my $name = shift;
	if($type eq 'server')
	{
		if(defined($servercmds{$name}))
		{
			return $servercmds{$name};
		}
		else
		{
			return -1;
		}
	}
	else
	{
		if(defined($clientcmds{$name}))
		{
			return $clientcmds{$name};
		}
		else
		{
			return -1;
		}
	}
}
sub getListofCmds{
	my $type = shift;
	if($type eq 'server')
	{
		return keys %servercmds;
	}
	else
	{
		return keys %clientcmds;
	}
}
sub getCmdsVals{
	my $type = shift;
	if($type eq 'server')
	{
		return  %servercmds;
	}
	else
	{
		return  %clientcmds;
	}
}


package CHandler;

my %cmd_handler =(
	'INTRO'=>sub{
		
		my $content = BogoContent->new;
		my %msgcontent;
		
		print "\n   Create content for command INTRO  \n";
		$msgcontent{'test'} = 0;
		print "Enter Client Version:";
		chomp($msgcontent{'clientVer'} = <>);
		print "Enter Game Id:";
		chomp($msgcontent{'gameId'} = <>);
		$content->setdata(\%msgcontent);
		$content->{FORMAT}="i i";
		$content->{MCONTENT} = pack($content->{FORMAT}, $msgcontent{'clientVer'}, $msgcontent{'gameId'});
		return $content;
	},
	'READY' => sub{
		my $content = BogoContent->new;
		my %msgcontent;
		$msgcontent{'test'} = 0;
		print "\n   Create content for command READY  \n";
		$content->setdata(\%msgcontent);
		return $content;
	},
	'GET_STATUS' => sub{
		my %msgcontent;
		$msgcontent{'test'} = 0;
		print "\n   Create content for command GET_STATUS  \n";
		return %msgcontent;
	},
	'THROW_DIES' => sub{
		my %msgcontent;
		$msgcontent{'test'} = 0;
		print "\n   Create content for command THROW_DIES  \n";
		return %msgcontent;
	},
	'MOVE_DONE' => sub{
		my %msgcontent;
		print "\n   Create content for command MOVE_DONE  \n";
		return %msgcontent;
	},
	'AC_NONE' => sub{
		my %msgcontent;
		print "\n   Create content for command INTRO  \n";
		return %msgcontent;
	},
	'DISCONNECT' => sub{
		my %msgcontent;
		print "\n   Create content for command DISCONNECT  \n";
		return %msgcontent;
	}
	
);

sub new{
	my $class = shift;
	my $self = bless{
		COMMANDS=>\%cmd_handler
	}, $class;
	return $self;
}

1;